package com.dingli.admin.controller;

import com.dingli.admin.service.IAreaService;
import com.dingli.framework.entity.Area;
import com.dingli.framework.util.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin("*")
@RestController
@RequestMapping("/area")
@Api(tags = "地区管理")
public class AreaController {
    @Autowired
    private IAreaService iAreaService;

    @GetMapping("/allArea")
    @ApiOperation("查询所有地区")
    public Object allArea() {
        return iAreaService.allArea();
    }

    @GetMapping("/selectById")
    @ApiOperation("指定地区信息查询")
    public Response<Area> selectById(@ApiParam("地域ID") @RequestParam Long
                                             areaId) {
        return iAreaService.selectById(areaId);
    }

    @GetMapping("/selectByParentId")
    @ApiOperation("子地区列表查询")
    public Object selectByParentId(@ApiParam("父地区ID") @RequestParam Long
                                           parentId) {
        return iAreaService.selectByParentId(parentId);
    }

}
